var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
    })(t, e);
}, function(t, e) {
    function i() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, 
    new i());
}), a = this && this.__decorate || function(t, e, o, i) {
    var n, a = arguments.length, s = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, o, i); else for (var r = t.length - 1; 0 <= r; r--) (n = t[r]) && (s = (a < 3 ? n(s) : 3 < a ? n(e, o, s) : n(e, o)) || s);
    return 3 < a && s && Object.defineProperty(e, o, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("Global"), s = e("PetManager"), c = e("TimeView"), l = e("GameConfig"), d = e("GameData"), u = e("UIManager"), p = cc._decorator, h = p.ccclass, f = p.property, g = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.skeleton = null, t.timeView = null, t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        u.default.getInstance().petShows.push(this);
    }, t.prototype.onDestroy = function() {
        var t = u.default.getInstance().petShows.indexOf(this);
        -1 < t && u.default.getInstance().petShows.splice(t, 1);
    }, t.prototype.onEnable = function() {
        var t = this;
        1 != d.GD.petDataIdx || s.default.getInstance().isHas(1) || cc.systemEvent.on("hatch_show", function() {
            cc.systemEvent.off("hatch_show"), t.refresh();
        });
    }, t.prototype.onDisable = function() {
        this.unscheduleAllCallbacks(), cc.systemEvent.off("hatch_show");
    }, t.prototype.start = function() {}, t.prototype.refresh = function() {
        if (2 == d.GD.petDataIdx) this.timeView && (this.timeView.node.active = !1); else {
            if (!s.default.getInstance().isHas()) {
                if (1 == d.GD.petDataIdx ? this.skeleton.setAnimation(0, "fall", !0) : this.skeleton.setAnimation(0, "fall", !1), 
                this.timeView) {
                    this.timeView.node.active = !0;
                    for (var t = 0, e = 0; e < d.GD.dailyInfo.length && 1 == d.GD.dailyInfo[e]; e++) t = e + 1;
                    for (var o = 0, e = 0; e < l.GC.dailyRewardList.length && (o = e, 0 != d.GD.petDataIdx || l.GC.dailyRewardList[e].type != r.RewardType.PET) && (1 != d.GD.petDataIdx || l.GC.dailyRewardList[e].type != r.RewardType.DRAGON); e++);
                    cc.log("idx", t, "targetIdx", o), this.showTimer(o, t);
                }
                return;
            }
            this.timeView && (this.timeView.node.active = !1);
        }
        .3 < s.default.getInstance().getRealHp() / s.default.getInstance().getHp() ? this.skeleton.setAnimation(0, "move2", !0) : 1 == d.GD.petDataIdx ? this.skeleton.setAnimation(0, "fall", !0) : this.skeleton.setAnimation(0, "fall", !1);
    }, t.prototype.showTimer = function(t, e) {
        this.timeView.node.active = !0, GA.isToday(d.GD.signLastTime) && e--, t <= e ? this.timeView.init(0) : (this.timeView.init(86400 * (t - e) - Math.floor(Date.now() / 1e3) + Math.floor(new Date().setHours(0, 0, 0, 0) / 1e3)), 
        this.timeView.startTimer());
    }, a([ f(sp.Skeleton) ], t.prototype, "skeleton", void 0), a([ f(c.default) ], t.prototype, "timeView", void 0), 
    a([ h ], t);
}(cc.Component);

n.default = g;